package leetcode.offer_two_special.array;

/**
 * @author mazouri
 * @create 2021-09-04 23:28
 */
public class _06_twoSum {
    public int[] twoSum(int[] numbers, int target) {
        int left = 0;
        int right = numbers.length - 1;
        int sum;

        while (left < right) {
            sum = numbers[left] + numbers[right];
            if (sum == target) return new int[]{left, right};
            else if (sum > target) right--;
            else left++;
        }
        return new int[2];
    }

    public static void main(String[] args) {

    }
}
